<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Vue中使用animate.css库</title>
    <script src="../lib/vue.js" type="text/javascript" charset="utf-8"></script>
    <link rel="stylesheet" type="text/css" href="../lib/animate.css">
</head>
<body>
<!--    添加放大和缩小的动态效果-->
<!--自定义 enter-active-class 和 leave-active-class
enter-active-class="active"
leave-active-class="leave"-->
<div id="root">
    <transition
            name="fade"
            enter-active-class="animated fadeInUp"
            leave-active-class="animated shake"
    >
        <div v-if="show">hello world</div>
    </transition>
    <button @click="handleClick">切换</button>
</div>
<script type="text/javascript">
    var vm = new Vue({
        el: "#root",
        data: {
            show: true
        },
        methods: {
            handleClick: function () {
                this.show = !this.show
            }
        },
    });
</script>
<style type="text/css">
    /*定义CSS3的动画*/
    @keyframes bounce-in {
        0% {
            transform: scale(0);
        }
        50% {
            transform: scale(1.5);
        }
        100% {
            transform: scale(1);
        }
    }

    /*显示时：第二帧出现，整个生命周期都存在，监听 transition 的变化*/
    .fade-enter-active {
        transform-origin: left center;
        animation: bounce-in 1s;
    }

    /*隐藏时：整个生命周期都存在，动画结束后才被取消，监听 transition 的变化*/
    .fade-leave-active {
        transform-origin: left center;
        animation: bounce-in 1s reverse;
    }
    /*显示时：使用自定义 enter-active-class 样式*/
    .active {
        transform-origin: left center;
        animation: bounce-in 1s;
    }

    /*隐藏时：使用自定义 leave-active-class 样式*/
    .leave {
        transform-origin: left center;
        animation: bounce-in 1s reverse;
    }
</style>
</body>
</html>
